-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[Sema/SILGen/IRGen/StdLib] Implement metatype keypaths #73242
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Sema/SILGen/IRGen/StdLib] Implement metatype keypaths #73242
Conversation
a1b2bb5
to
0ec01dc
Compare
// CHECK: true | ||
print(keyPath3FromLibB == keyPath3FromLibC) | ||
// CHECK: true | ||
print(keyPath3FromLibB != keyPath4FromLibC) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@amritpan I think we need a lot more tests. Could you please add tests that access static properties and subscripts to test/SILGen/keypaths.swift
, we also need chained access tests in Sema and in SILGen and interpreter tests for all of the above that make sure that changes behave as expected at runtime.
lib/SIL/Verifier/SILVerifier.cpp
Outdated
@@ -7192,6 +7192,8 @@ void SILProperty::verify(const SILModule &M) const { | |||
auto sig = dc->getGenericSignatureOfContext(); | |||
auto baseTy = dc->getInnermostTypeContext()->getSelfInterfaceType() | |||
->getReducedType(sig); | |||
if (decl->isStatic()) | |||
baseTy = CanMetatypeType::get(baseTy); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since retrieval of the base type is not as straightforward anymore I think it should either become a property of SILProperty
or we should add a method on SILProperty i.e. CanType SILProperty::getBaseType() const
to compute it internally.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added CanType SILProperty::getBaseType() const
to SILVerifier.cpp above ::verify
and don't think that is the place for it but am not sure where else it should go. Perhaps at the end of SILType.cpp?
bc8d04b
to
71bc3a6
Compare
@swift-ci please build toolchain macOS platform |
@swift-ci please build toolchain Linux platform |
@@ -1050,6 +1050,7 @@ _$sSP17withMemoryRebound2to8capacity_qd_0_qd__m_Siqd_0_SPyqd__GKXEtKr0_lF | |||
_$sSP25customPlaygroundQuickLooks01_bcD0Ovg | |||
_$sSP25customPlaygroundQuickLooks01_bcD0OvpMV | |||
_$sSP4_maxSPyxGvgZ | |||
_$sSP4_maxSPyxGvpZMV |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should edit abi/macOS/{arch}/stdlib.swift
instead of adding these to the baselines. Also, do we have to emit these property descriptors for every static property? Can we make these conditionally emittable?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you - I've moved them over. And yes, with this implementation, we will need to emit property descriptors for every static property.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Similarly with the other baseline-asserts 😅
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you! I've moved the rest over as well.
96fda00
to
ebd7dfc
Compare
ebd7dfc
to
bd773b7
Compare
@swift-ci please build toolchain macOS platform |
bd773b7
to
5e4b371
Compare
5e4b371
to
ed098bb
Compare
ed098bb
to
5ed66f1
Compare
162cdaa
to
6778a34
Compare
@swift-ci please test |
6778a34
to
4e63e02
Compare
@swift-ci please test |
Glad to see this long-awaited feature is in progress :-) |
4e63e02
to
1865936
Compare
@swift-ci please test |
1865936
to
fa51809
Compare
fa51809
to
8ebc928
Compare
@swift-ci please smoke test |
It looks like some of the tests now need to be marked
Instead, it would be better to split off the tests for the new feature into their own file(s). |
@amritpan could you please all the tests where you added the flat? Looks like we didn’t get all of them |
We are seeing swift macOS toolchain bot failing most likely related to this PR.
|
@amritpan could you please take a look? |
@shahmishal I've opened this PR to resolve this. Thank you! |
@slavapestov Created this PR: #76824 |
Originally added in swiftlang#73242. swiftlang#76826 was up to remove them but we took swiftlang#76824 instead. Resolves rdar://136918801.
Originally added in swiftlang#73242. swiftlang#76826 was up to remove them but we took swiftlang#76824 instead. Resolves rdar://136918801.
@shahmishal It seems that the abi test failures are persisting? I've reopened #76826. |
This is the implementation for SE-0438: Metatype Keypaths which extends keypath usage to include references to static properties, eg. metatype keypaths: